{% extends "block/main.html" %}

{% block title %} Login {% endblock %}

{% block nav %}{% endblock %}

{% block binfo %}
style="background-color: #c3c3c3;"
{% endblock %}

{% block main %}
<br />


<div class="card">
    <div class="card-body">
        <h5 class="card-title">LyDev - Sign In</h5>
        <form id="form">
            <div class="form-group">
                <label for="password">登录密码</label>
                <input type="password" class="form-control" id="password" aria-describedby="passwordHelp">
                <small id="passwordHelp" class="form-text text-muted">
                    如果您是第一次登录，请使用默认密码 :) &nbsp;<strong>123456</strong> &nbsp;
                    登录后请立刻更改密码！
                </small>
            </div>

            <button type="submit" class="btn btn-info btn-block">登录后台</button>
        </form>
    </div>
</div><br />

<div class="card">
    <div class="card-body" style="font-size: 12px;text-align: center;">
        LyDev 支持开发者在线对拓展进行安装、管理等操作（储存使用
        <a href="https://www.oschina.net/news/98196/cutedb-v1-0-released?nocache=1532227904121" target="_bank">
            CuteDB
        </a>
        ）
    </div>
</div>
{% endblock %}

{% block script %}

<script>
    $("#form").submit(function () {

        var pwd = $("#password").val();
        if (pwd != "") {
            $.ajax({
                type: "POST",
                url: "/@dev/login",
                data: {
                    password: pwd
                },
                success: function (res) {
                    if (res == "OK") {
                        layer.msg("登录成功！即将自动跳转！");
                        
                        setTimeout(function () {
                            window.location.href = "/@dev";
                        }, 1200);
                    }
                },
                error: function (res) {
                    layer.msg(JSON.stringify(res));
                }
            });
        }

        return false;
    });
</script>

{% endblock %}